package com.gnight.staticUtils;/*
 *  @author: G_night
 *  转载请申明作者
 *  Reprint please state the author
 */

import com.aliyun.com.viapi.FileUtils;
import com.aliyun.oss.ClientException;
import java.io.IOException;


/**
 * 创建oss连接，该连接有效期在2天以内
 * 此为工具类，只需要修改下面两个参数，用自己的key
 * @Param accessKey
 * @Param accessKeySecret
 **/
public class createOssUrl {
    public static String testUploadFile(String path) throws ClientException, IOException {
        //下面填入自己的key和keysecret
        String accessKey = "";
        String accessKeySecret = "";
        String file = path;//传入的地址
        FileUtils fileUtils = null;
        try {
            fileUtils = FileUtils.getInstance(accessKey,accessKeySecret);
            String ossurl = fileUtils.upload(file);
            return ossurl;
        } catch (com.aliyuncs.exceptions.ClientException e) {
            e.printStackTrace();
        }
        return null;
    }
}
